//DO NOT CHANGE THIS PACKAGE
package coursework3;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cw3interfaces.CommunityGroupInterface;


//DO NOT CHANGE THIS NAME
public class CommunityGroup implements CommunityGroupInterface {
    
    private final List<String> volunteers = new ArrayList<>();
    
    private final static Map<String,Integer> skillNames = new HashMap<>();
    
    public int [] skillNumber = new int[] {0,0,0,0,0};
    
    static {
    	skillNames.put("A", 0);
    	skillNames.put("B", 1);
    	skillNames.put("C", 2);
    	skillNames.put("D", 3);
    	skillNames.put("E", 4);
    }
    
 //COMPLETE THIS CLASS    
    private String groupName ;
    
    public CommunityGroup(String groupName) {
    	this.groupName = groupName;
    }
       
    
 //these public methods need to form the interface 
// DO NOT CHANGE ANY OF THESE METHOD NAMES, RETURN VALUES, OR ARGUMENTS   
    public int howManyVolunteers(){
        //return the total number of volunteers in this community group
        //COMPLETE CODE HERE
        return volunteers.size();
    }
    
    public void statistics() {
    	skillNumber = new int[] {0,0,0,0,0};
    	for( String skill : volunteers ) {
    		for( char c : skill.toCharArray() ) {
    			skillNumber[ skillNames.get(String.valueOf(c)).intValue() ] ++;
    		}
    	}
    }
    
    public String getSkillsTotals(){
        // return the total number of each skill in a String, example:
        //Skill A: 13, Skill B: 20, Skill C: 23, Skill D: 5, Skill E: 41
        //COMPLETE CODE HERE
    	statistics();
    	Integer volict = 0;
    	for(Integer sn : skillNumber) {
    		volict += sn;
    	}
        return this.groupName+"|\t"+"Skill A:"+skillNumber[0]+"\t|\tSkill B:"+skillNumber[1]+"\t|\t"
        		+ "Skill C:"+skillNumber[2]+"\t|\tSkill D:"+skillNumber[3]+"\t|\tSkill E:"+skillNumber[4]+"\t|\ttotal"
        				+ ":"+volict;
    }


	public String getGroupName() {
		return groupName;
	}


	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}


	public List<String> getVolunteers() {
		return volunteers;
	}

	

}
